<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@page import="com.opensymphony.xwork2.ActionContext;" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	  <head>
	    <base href="<%=basePath%>">
	    <title>add_room.jsp</title>
	    
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">    
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		
		<link rel="stylesheet" type="text/css" href="./css/style.css">
		<style type="text/css">
			.dashed {border-bottom:1px dashed;}
			.mask{position: absolute;
			top: 0px;
			left: 0px;
			filter: alpha(opacity=50);
			-moz-opacity:0.5;
			opacity:0.5;
			background-color: #ffffff;
			z-index: 2;
			display: none;}
			 /*  弹出基本资料div */
			div.sample_popup {height:auto; border: 1px solid #327eca; width: 300px;}
			div.menu_form_header{
			 background: url('/image/1.jpg') repeat-x;
			}
			div.sample_popup div.menu_form_header
			{
			  border-bottom: 0px;
			  cursor: default;
			  width:100%;
			  height:      22px;
			  line-height: 22px;
			  vertical-align: middle;
			  text-decoration: none;
			  font-family: "Times New Roman", Serif;
			  font-weight: 800;
			  font-size: 13px;
			  color: #206040;
			}
			div.menu_form_body
			{
			  width:100%;
			  height:250px;
			  font-size:12px;
			  background-color:#f1f8fe;
			}
			div.sample_popup input.menu_form_exit
			{
			  float: right;
			  margin: 4px 5px 0px 0px;
			  cursor: pointer;
			}
			/*end:  弹出商品信息div */
    	</style>
		<SCRIPT type="text/javascript">
			var loglist;
			function message(){
				var d1=document.getElementById("show10").style.display="none";
				var d1=document.getElementById("showall").style.display="block";
			}
			function message2(){
				var d1=document.getElementById("showall").style.display="none";
			}
			function message3(){
				var d1=document.getElementById("show10").style.display="block";
				var d1=document.getElementById("showall").style.display="none";
			}
			function showallmsg(){
				alert("ok");
			}
		
		
			var DivWindow= function(popup/*最外层div id*/,popup_drag/*拖动div id*/,popup_exit/*退出按钮id*/ ,exitButton/*触发服务器端退出按钮id*/
				,varwidth,varheight,zindex){
			 	this.popup =popup ; //窗口名称
			  	this.popup_drag=popup_drag;
			 	this.height =varheight ; //窗口高度，并没用来设置窗口高度宽度，用来定位在屏幕的位置
			 	this.width =varwidth ; //窗口宽度
			    this.popup_exit=popup_exit;
			    this.exitButton=exitButton;
			    this.zindex=zindex;
			 	this.init = function(){ //初始化窗口
			  	this.popupShow();
			  	this.startDrag(); //设置拖动
			  	this.setCommond(); //设置关闭
			  	DivWindow.ArrayW.push(document.getElementById(this.popup)); //存储窗口到数组
		 	};
		 	this.init();
		};
		//存储窗口到数组
		DivWindow.ArrayW = new Array();
		//字符串连接类
		DivWindow.StringBuild = function(){
		 	this.arr = new Array();
		 	this.push = function(str){
		  	this.arr.push(str);
		};
		this.toString = function(){
		return this.arr.join("");
		};
	};

	//拖动类
	DivWindow.Drag = function(o ,oRoot){
	 var _self = this;
	 //拖动对象
	 this.obj = (typeof oRoot != "undefined") ?oRoot : o;
	 this.relLeft = 0; //记录横坐标
	 this.relTop = 0; //记录纵坐标
	 o.onselectstart = function(){
	  return false;
	 };
	 o.onmousedown = function(e){ //鼠标按下
	  e = _self.fixE(e);
	  _self.relLeft = e.clientX - _self.fixU(_self.obj.style.left);
	  _self.relTop = e.clientY - _self.fixU(_self.obj.style.top);
	  document.onmousemove = function(e){
	   _self.drag(e);
	   //_self.obj.style.border = "1px dashed #000000";
	   //_self.obj.style.filter = "alpha(opacity=30)";
	   //_self.obj.style.opacity = "0.3";
	  };
	  document.onmouseup  = function(){
	   _self.end();
	   //_self.obj.style.border = "1px solid #cccccc";
	   //_self.obj.style.borderBottom = "2px solid #E0E0E0";
	   //_self.obj.style.borderRight = "2px solid #E0E0E0";
	   //_self.obj.style.filter = "alpha(opacity=100)";
	   //_self.obj.style.opacity = "1";
	  };
	 };
	 this.drag = function(e){ //拖动
	  e = this.fixE(e);
	  var l = e.clientX - this.relLeft;
	  var t = e.clientY - this.relTop;
	  if (t < 0)
	  {
	   t = 0; //防止头部消失
	  }
	  this.obj.style.left = l +"px";
	  this.obj.style.top = t +"px";
	 };
	 this.end = function(){ //结束拖动
	  document.onmousemove = null;
	  document.onmouseup = null;
	 };
	 this.fixE = function(e){ //修复事件
	  if (typeof e == "undefined") e = window.event;
	  return e;
	 };
	 this.fixU = function(u){ //处理px单位
	  return parseInt(u.split("p")[0]);
	 };
	};//欢迎来到站长特效网，我们的网址是www.zzjs.net，很好记，zz站长，js就是js特效，本站收集大量高质量js代码，还有许多广告代码下载。
	//窗口拖动
	DivWindow.prototype.startDrag = function(){
	 var obj = document.getElementById(this.popup);
	        var drag = document.getElementById(this.popup_drag);
	 new DivWindow.Drag(drag,obj);
	};
	//设定窗口优先级
	DivWindow.prototype.setTop = function(){
	 document.getElementById(this.popup).onclick =
	 document.getElementById(this.popup).onmousedown =
	 function(){
	  for(var i=0;i<DivWindow.ArrayW.length;i++)
	  {
	   DivWindow.ArrayW[i].style.zIndex = 1;
	  }
	  this.style.zIndex = 100;
	 };
	};
	//显示
	DivWindow.prototype.popupShow=function()
	{       document.getElementById('mask').style.display="block";
	        document.getElementById('mask').style.width=window.screen.width-50;
	        document.getElementById('mask').style.height=window.screen.width-50;
	        var  element = document.getElementById(this.popup);
	        element.style.position   = "absolute";
	        element.style.visibility = "visible";
	        element.style.display    = "block";
	        element.style.width=this.width;
	        element.style.height='auto';
	        element.style.left = (window.screen.width - this.width)/2+"px";
	        
	        //element.style.top  =(window.screen.height-this.height-100)/2+"px";
	        element.style.top  =120+"px";
	        element.style.zIndex=this.zindex;
	}
	//设置关闭
	DivWindow.prototype.setCommond = function(){
	 var _self = this;
	 //根对象
	 var obj = document.getElementById(this.popup);
	 var exit = document.getElementById(this.popup_exit);
	 var triggServerEvent=document.getElementById(this.exitButton);
	//欢迎来到站长特效网，我们的网址是www.zzjs.net，很好记，zz站长，js就是js特效，本站收集大量高质量js代码，还有许多广告代码下载。
	 //设置关闭
	             exit.onclick = function(){
	      obj.style.display = "none";
	      obj.style.visibility = 'hidden';
	                    document.all.mask.style.display='none'//关闭遮罩层
	                    triggServerEvent.click();//触发服务器端退出事件
	     };
	};//欢迎来到站长特效网，我们的网址是www.zzjs.net，

		function showInfo(value){
			var info = document.getElementById("info");
			var str = value.split("在");
			var name = str[0];
			var time = str[1].substr(0,19);
			var action = str[1].substr(19);
			info.innerHTML = "<table cellpadding='5' cellspacing='5' border='0' align='center'>"+
								"<tr>"+
									"<td>操作人:</td>"+
									"<td>"+name+"</td>"+
								"</tr>"+
								"<tr>"+
									"<td>时间:</td>"+
									"<td>"+time+"</td>"+
								"</tr>"+
								"<tr>"+
									"<td valign='top'>动作:</td>"+
									"<td><textarea rows='6' cols='60' style='border:0px;background-color:#f1f8fe;' readonly>"+action+"</textarea></td>"+
								"</tr>"+
							"</table>";
			new DivWindow('popup','popup_drag','popup_exit','exitButton','600','200',4);
		}
		
		function showPart(value){
			var content = document.getElementById("content");
			var current = document.getElementById("currentPage");
			var total = document.getElementById("totalPages");
			var currentPage = parseInt(current.innerHTML);
			var pages = parseInt(total.innerHTML);
			switch(value){
				case 1: page = 1;break;
				case 2: page = currentPage - 1;break;
				case 3: page = currentPage + 1;break;
				case 4: page = pages;break;
				default:break;
			}
			if(page<1){
				page = 1;
			}
			if(page>pages){
				page = pages;
			}
			var start = (page-1)*10;
			var end = start + 10;
		
			var text="";
			var i = 0;
			for(i=start;i<end&i<loglist.length;i++){
				var value = loglist[i];
				var show;
				if(value.length>50){
					show = value.substring(0,50)+"&nbsp;&nbsp;...";
				}else{
					show = value;
				}
				text += "<img src='./images/dot2.gif'/>"+
						"<span><font size='4' color='red'>"+
						"<a style='text-decoration:none;cursor: pointer;' onclick='showInfo(\""+value+"\")'>"+
							show+
						"</a>"+
						"</font></span><br/><br />";
			}
			current.innerHTML = page;
			total.innerHTML = pages;
			content.innerHTML = text;
			var last = document.getElementById("last");
			var next = document.getElementById("next");
			if(page<=1){
				last.innerHTML = "&lt;&lt; 首页 &lt; 上一页";
			}else{
				last.innerHTML = "<a onclick='showPart(1)' style='cursor:pointer;' > &lt;&lt;首页</a>"+
								 "<a onclick='showPart(2)' style='cursor:pointer;' >&lt; 上一页 </a>";
			}
			if(page<pages){
				next.innerHTML = "<a onclick='showPart(3)' style='cursor:pointer;' > 下一页 &gt;</a>"+
								 "<a onclick='showPart(4)' style='cursor:pointer;' >末页 &gt;&gt;</a>";
				
			}else{
				next.innerHTML = "下一页 &gt;末页 &gt;&gt;";
			}
		}
		function load(){
			var total = document.getElementById("totalPages");
			var pages;
			var num = ${fn:length(loglist)}+1;
			if((num%10==0)||(num%10>=5)){
				pages = <fmt:formatNumber type="number" value="${fn:length(loglist)/10}" maxFractionDigits="0"/>;
			}else{
				pages = <fmt:formatNumber type="number" value="${fn:length(loglist)/10+1}" maxFractionDigits="0"/>;
			}
			total.innerHTML = pages;
		
			var last = document.getElementById("last");
			var next = document.getElementById("next");
			last.innerHTML = "&lt;&lt; 首页 &lt; 上一页";
			if(pages>1){
				next.innerHTML = "<a onclick='showPart(3)' style='cursor:pointer;' > 下一页 &gt;</a>"+
								 "<a onclick='showPart(4)' style='cursor:pointer;' >末页 &gt;&gt;</a>";
			}else{
				next.innerHTML = "下一页 &gt;末页 &gt;&gt;";
			}
		
			loglist = new Array(<%	
					Object obj = ActionContext.getContext().get("loglist");
					List<String> loglist = (List<String>)obj;
					out.print("\"");
					out.print(loglist.get(0));
					out.print("\"");
					for(int i=1;i<loglist.size();i++){
						out.print(",");
						out.print("\"");
						out.print(loglist.get(i));
						out.print("\"");
					}	
					%>);
			showPart(1);
		}	
	</SCRIPT>
	</head>
	  
	  <body onload="load()">
	  		<c:set var="list">${loglist}</c:set>
		    <div id="blue_button"><div id="blue_button_word">&nbsp;日志列表</div></div>
		  	<div id="right_background">&nbsp;<br/> <br/> 
			  	<div align="left" id="show10" style="margin-left:60px;">
					<font id="content" ></font>
				</div>
				<div align="left"  style="margin-left:30px;">
					<p class="paging">
						<font id="last"></font>
						<strong>第<font id="currentPage">1</font>页/共<font id="totalPages"></font>页</strong>
						<font id="next"></font>
					</p>
				</div>
		  	</div>
		  	 <!-- 遮罩层 -->
 <div id="mask"  class="mask">
 </div>
<!-- 弹出基本资料详细DIV层 -->
<div class="sample_popup" id="popup" style="visibility: hidden; display: none;">
	<div class="menu_form_body" >
	 	<div id="popDetail">
	  		<font id="info"></font>
	    </div>
	   	<div class="menu_form_header" id="popup_drag" align="center">
	 		<input type="button"  class="add" id="popup_exit" value="返回"/>
		</div>
	</div>
</div>
</body>
</html>
